﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="KMrpt5.aspx.cs" Inherits="KMrpt5" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>单品销售库存报表</title>
    <style>
        .x-grid-row-over .x-grid-cell-inner
        {
            font-weight: bold;
        }
        .x-column-header-inner
        {
            height: 28px;
            background: #E7EBEF url(./images/header.png) repeat-x 0 0;
        }
    </style>
    <script type="text/javascript">

        var template = '<span style="color:{0};">{1}</span>';

        var change = function (value) {
            return Ext.String.format(template, (value > 0) ? "green" : "red", value);
        };

        var pctChange = function (value) {
            return Ext.String.format(template, (value > 0) ? "green" : "red", value + "%");
        };
        //导出EXCEL
        var exportData = function (format) {
            App.FormatType.setValue(format);
            var store = App.GridPanel1.store;

            store.submitData(null, { isUpload: true });
        };
        var areachange = function (obj) {
            //alert(obj.value);
            CompanyX.binStock(obj.value);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Neptune" />
        <ext:Store ID="Store1" runat="server" PageSize="100" OnReadData="MyData_Refresh"
            OnSubmitData="Store1_Submit">
            <Model>
                <ext:Model ID="Model1" runat="server" IDProperty="货品ID">
                    <Fields>
                        <ext:ModelField Name="货品ID" ServerMapping="MaterialID" Type="String" />
                        <ext:ModelField Name="货号" ServerMapping="MaterialCode" Type="String" />
                        <ext:ModelField Name="简称" ServerMapping="MaterialShortName" Type="String" />
                        <ext:ModelField Name="年份" ServerMapping="YearNo" Type="String" />
                        <ext:ModelField Name="颜色" ServerMapping="colorname" Type="String" />
                        <ext:ModelField Name="季节" ServerMapping="seasonname" Type="String" />
                        <ext:ModelField Name="系列" ServerMapping="seriesname" Type="String" />
                        <ext:ModelField Name="类别" ServerMapping="kindname" Type="String" />
                        <ext:ModelField Name="销售天数" ServerMapping="saldaycount" Type="Float" />
                        <ext:ModelField Name="销售店数" ServerMapping="dcount" Type="Float" />
                        <ext:ModelField Name="日均销量" ServerMapping="saldayqty" Type="Float" />
                        <ext:ModelField Name="期间销量" ServerMapping="salqty" Type="Float" />
                        <ext:ModelField Name="累销数量" ServerMapping="salsumqty" Type="Float" />
                        <ext:ModelField Name="店存数量" ServerMapping="dinvqty" Type="Float" />
                        <ext:ModelField Name="总存数量" ServerMapping="suminvqty" Type="Float" />
                        <ext:ModelField Name="总存流转周" ServerMapping="zlzz" Type="Float" />
                        <ext:ModelField Name="售罄率" ServerMapping="xxl" Type="String"/>
                        <ext:ModelField Name="未入库量" ServerMapping="unInQty" Type="Float" />
                        <ext:ModelField Name="期间折扣" ServerMapping="qjzkl" Type="String" />
                        <ext:ModelField Name="累计折扣" ServerMapping="ljzkl" Type="String" />
                        <ext:ModelField Name="库存店数" ServerMapping="scount" Type="Float" />
                        <ext:ModelField Name="出仓率" ServerMapping="ccl" Type="String" />
                        <ext:ModelField Name="店均存量" ServerMapping="djl" Type="Float" />
                        <ext:ModelField Name="店存流转周" ServerMapping="dlzz" Type="Float" />
                    </Fields>
                </ext:Model>
            </Model>
        </ext:Store>
        <ext:Viewport ID="Viewport1" runat="server" Layout="FitLayout">
            <Items>
                <ext:Hidden ID="FormatType" runat="server" />
                <ext:GridPanel ID="GridPanel1" runat="server" TitleAlign="Center">
                    <TopBar>
                        <ext:Toolbar  runat="server" Layout="Container">
                            <Items>
                                <ext:Toolbar ID="Toolbar1" runat="server">
                                    <Items>
                                        <ext:DateField runat="server" ID="txtbdate" FieldLabel="日期" LabelWidth="60" />
                                        <ext:Label runat="server" Text="-">
                                        </ext:Label>
                                        <ext:DateField runat="server" ID="txtedate" />
                                        <ext:MultiCombo runat="server" ID="txtarea" FieldLabel="地区" LabelWidth="60" DisplayField="OperationAreaName"
                                            ValueField="OperationAreaID">
                                            <Store>
                                                <ext:Store runat="server" ID="st_area">
                                                    <Model>
                                                        <ext:Model runat="server">
                                                            <Fields>
                                                                <ext:ModelField Name="OperationAreaID" />
                                                                <ext:ModelField Name="OperationAreaName" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                            <Items>
                                                <ext:ListItem>
                                                </ext:ListItem>
                                            </Items>
                                            <Listeners>
                                                <Change Fn="areachange" />
                                            </Listeners>
                                        </ext:MultiCombo>
                                        <ext:MultiCombo runat="server" ID="txtstock" FieldLabel="库存仓" LabelWidth="60" DisplayField="stockname"
                                            ValueField="stockid">
                                            <Store>
                                                <ext:Store runat="server" ID="st_stock">
                                                    <Model>
                                                        <ext:Model ID="Model2" runat="server">
                                                            <Fields>
                                                                <ext:ModelField Name="stockid" />
                                                                <ext:ModelField Name="stockname" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                            <Items>
                                                <ext:ListItem>
                                                </ext:ListItem>
                                            </Items>
                                        </ext:MultiCombo>
                                        <ext:Button ID="Button1" runat="server" Text="查询" OnDirectClick="BtnQureyUser" UI="Info">
                                            <DirectEvents>
                                                <Click Timeout="120000">
                                                    <EventMask ShowMask="true" Msg="加载中...">
                                                    </EventMask>
                                                </Click>
                                            </DirectEvents>
                                        </ext:Button>
                                    </Items>
                                </ext:Toolbar>
                                <ext:Toolbar runat="server">
                                    <Items>
                                        <ext:MultiCombo runat="server" ID="txtyear" FieldLabel="年份" LabelWidth="60" DisplayField="yearno"
                                            ValueField="yearno">
                                            <Store>
                                                <ext:Store runat="server" ID="Store2">
                                                    <Model>
                                                        <ext:Model ID="Model3" runat="server">
                                                            <Fields>
                                                                <ext:ModelField Name="yearno" />
                                                                <ext:ModelField Name="yearno" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                            <Items>
                                                <ext:ListItem>
                                                </ext:ListItem>
                                            </Items>
                                        </ext:MultiCombo>
                                        <ext:MultiCombo runat="server" ID="txtseason" FieldLabel="季节" LabelWidth="60" DisplayField="seasonname"
                                            ValueField="seasonname">
                                            <Store>
                                                <ext:Store runat="server" ID="Store3">
                                                    <Model>
                                                        <ext:Model ID="Model4" runat="server">
                                                            <Fields>
                                                                <ext:ModelField Name="seasonname" />
                                                                <ext:ModelField Name="seasonname" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                            <Items>
                                                <ext:ListItem>
                                                </ext:ListItem>
                                            </Items>
                                        </ext:MultiCombo>
                                        <ext:MultiCombo runat="server" ID="txtmatkind" FieldLabel="类别" LabelWidth="60" DisplayField="kindname"
                                            ValueField="kindname">
                                            <Store>
                                                <ext:Store runat="server" ID="Store4">
                                                    <Model>
                                                        <ext:Model ID="Model5" runat="server">
                                                            <Fields>
                                                                <ext:ModelField Name="kindname" />
                                                                <ext:ModelField Name="kindname" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                            <Items>
                                                <ext:ListItem>
                                                </ext:ListItem>
                                            </Items>
                                        </ext:MultiCombo>
                                        <ext:TextField runat="server" ID="txtmatcode" FieldLabel="货号" LabelWidth="60" />
                                        <ext:TextField runat="server" ID="txtmatname" FieldLabel="货品简称" LabelWidth="60" />
                                    </Items>
                                </ext:Toolbar>
                                <ext:Toolbar runat="server">
                                    <Items>
                                        <ext:Label  runat="server" Text="温馨提示：涉及到库存计算的报表，等待时间会比较久一点，请耐心等待！" StyleSpec="color:red;"></ext:Label>
                                    </Items>
                                </ext:Toolbar>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <ColumnModel>
                    </ColumnModel>
                    <Features>
                        <ext:Summary runat="server">
                        </ext:Summary>
                    </Features>
                    <SelectionModel>
                        <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
                    </SelectionModel>
                    <BottomBar>
                        <ext:PagingToolbar ID="PagingToolbar1" runat="server">
                            <Items>
                                <ext:Label ID="Label1" runat="server" Text="每页显示:" />
                                <ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
                                <ext:ComboBox ID="ComboBox1" runat="server" Width="80">
                                    <Items>
                                        <ext:ListItem Text="100" />
                                        <ext:ListItem Text="200" />
                                        <ext:ListItem Text="500" />
                                        <ext:ListItem Text="1000" />
                                    </Items>
                                    <SelectedItems>
                                        <ext:ListItem Value="100" />
                                    </SelectedItems>
                                    <Listeners>
                                        <Select Handler="#{GridPanel1}.store.pageSize = parseInt(this.getValue(), 10); #{GridPanel1}.store.reload();" />
                                    </Listeners>
                                </ext:ComboBox>
                                <ext:Button ID="Button2" runat="server" Text="导出Excel" Icon="PageExcel">
                                    <Listeners>
                                        <Click Handler="exportData('xls');" />
                                    </Listeners>
                                </ext:Button>
                            </Items>
                            <Plugins>
                                <ext:ProgressBarPager ID="ProgressBarPager1" runat="server" />
                            </Plugins>
                        </ext:PagingToolbar>
                    </BottomBar>
                </ext:GridPanel>
            </Items>
        </ext:Viewport>
    </div>
    </form>
</body>
</html>
